package rsp

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Fail(ctx *gin.Context, err error) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": 403,
		"msg":  err.Error(),
	})
}

func FailWithMsg(ctx *gin.Context, msg string) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": 403,
		"msg":  msg,
	})
}

func Success(ctx *gin.Context, data any) {
	ctx.JSON(http.StatusOK, gin.H{
		"code": 200,
		"data": data,
	})
}

func Abort(ctx *gin.Context, msg string) {
	ctx.AbortWithStatusJSON(200, gin.H{
		"code": 403,
		"msg":  msg,
	})
}
